package display;

import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics;


public class Canvas_LEDBar extends Canvas{
/**
	 * 
	 */
private static final long serialVersionUID = 1L;



public enum Orientation  {HORIZONTAL,VERTICAL};

private RGBColor  ledBarData[];	


private Orientation barOrientation;
//TODO Bkg Image (Image Mode)
private static final int CellSize=31;

public Canvas_LEDBar(RGBColor  [] newLEDBarData,Orientation barOrientation)
{
	int counter;
	
	this.ledBarData=newLEDBarData;
	this.barOrientation=barOrientation;
	
	for (counter=0;counter<ledBarData.length;counter++)
		{
		ledBarData[counter]=new RGBColor((short)0);
		}


}


//public void update(Graphics MyGraphics)
public void paint(Graphics MyGraphics)
{

	
	int iCounter;
	int xPos;
	int yPos;
	
	xPos=0;
	yPos=0;
	
	for (iCounter=0;iCounter<ledBarData.length;iCounter++)
	{
		
		MyGraphics.setColor(Color.DARK_GRAY);
		MyGraphics.fillOval(xPos, yPos,CellSize,CellSize);

		
		if (barOrientation==Orientation.HORIZONTAL)
			{
			xPos+=CellSize;
			}

		if (barOrientation==Orientation.VERTICAL)
			{
			yPos+=CellSize;
			}
	}

	paintLEDs(MyGraphics);
}

public void paintLEDs(Graphics MyGraphics)
{

	
	int iCounter;
	int xPos;
	int yPos;
	
	xPos=0;
	yPos=0;
	
	for (iCounter=0;iCounter<ledBarData.length;iCounter++)
	{
		
		
		MyGraphics.setColor(ledBarData[iCounter].GetColor());	
		
		MyGraphics.fillOval(xPos+2, yPos+2,CellSize-3,CellSize-3);
	
		if (barOrientation==Orientation.HORIZONTAL)
			{
			xPos+=CellSize;
			}

		if (barOrientation==Orientation.VERTICAL)
			{
			yPos+=CellSize;
			}

	}
}


}
